# 先对配置文件进编写
import logging

from redis import StrictRedis


class Config(object):
    # 链接数据库
    SQLALCHEMY_DATABASE_URI = 'mysql://root:root@127.0.0.1:3306/toutiao'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True # 每次请求结束都会自动提交事务
    # 配置redis
    REDIS_HOST = '127.0.0.1'
    REDIS_PSRT = 6379
    # 配置session
    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQus8yCM6xX9Yjq52v54g+HVoknA"
    SESSION_TYPE = "redis"  # 指定session 保存到 redis 中
    SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PSRT)
    PERMANENT_SESSION_LIFETIME = 86400  # session 的有效期，单位是秒


class ProductConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.ERROR


class DevelopmenConfig(Config):
    DEBUG = True
    LOG_LEVEL = logging.ERROR


config_dic = {
    'Developmen': DevelopmenConfig,
    'Product': ProductConfig
}
